/**
 * Copyright (c) 2012-2014, Yang Yang <cntototo@gmail.com>
 *
 * This software may be distributed under the terms of the New BSD License.
 * See README for more details.
 */

#ifndef IF_MANAGER_H
#define IF_MANAGER_H

#include "def.h"
#include "queue.h"

/**
 * struct wfs_iface_input -- Input info digested by interface manager
 */
struct wfs_iface_input {
	/** Interface name */
	char *ifname;
	/** Port of command socket's destination address */
	unsigned short cmd_port_dest;
	/** Port of event socket's destination address */
	unsigned short evt_port_dest;
};

/**
 * struct wfs_iface -- Keeps the info specific to each interface
 */
struct wfs_iface {
	/** Global info of WFS daemon */
	struct wfs_global *global;
	/** Debug level */
	int debug_level;
	/** Interface name */
	char ifname[IFNAMSIZ + 1];
	/** Port of command socket's destination address */
	unsigned short cmd_port_dest;
	/** Port of event socket's destination address */
	unsigned short evt_port_dest;
	/** Driver ops */
	struct wfs_driver_ops *driver_ops;
	/** Driver info */
	void *driver_info;
#ifdef CONFIG_STA
	/** STA info */
	struct wfs_sta_info *sta_info;
#endif

	SLIST_ENTRY(wfs_iface) list_item;
};

/**
 * wfs_iface_add -- Add a new interface into WFS
 */
enum wfs_internal_err wfs_iface_add(const struct wfs_iface_input *input,
		struct wfs_global *global);

/**
 * wfs_iface_remove -- Remove the interface from WFS
 */
enum wfs_internal_err wfs_iface_remove(const struct wfs_iface_input *input);

/**
 * wfs_iface_remove_all -- Remove all interfaces from WFS
 */
enum wfs_internal_err wfs_iface_remove_all(void);

/**
 * wfs_get_iface -- Get wfs_iface structure by interface name
 */
struct wfs_iface *wfs_get_iface(const struct wfs_iface_input *input);

#endif /* IF_MANAGER_H */
